/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package EA_Model.IEC61970.Wires.impl;

import EA_Model.IEC61970.Core.impl.ConductingEquipmentImpl;

import EA_Model.IEC61970.Domain.ActivePower;
import EA_Model.IEC61970.Domain.AngleRadians;
import EA_Model.IEC61970.Domain.Reactance;
import EA_Model.IEC61970.Domain.Resistance;
import EA_Model.IEC61970.Domain.Voltage;

import EA_Model.IEC61970.Wires.EnergySource;
import EA_Model.IEC61970.Wires.WiresPackage;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Energy Source</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link EA_Model.IEC61970.Wires.impl.EnergySourceImpl#getActivePower <em>Active Power</em>}</li>
 *   <li>{@link EA_Model.IEC61970.Wires.impl.EnergySourceImpl#getNominalVoltage <em>Nominal Voltage</em>}</li>
 *   <li>{@link EA_Model.IEC61970.Wires.impl.EnergySourceImpl#getR <em>R</em>}</li>
 *   <li>{@link EA_Model.IEC61970.Wires.impl.EnergySourceImpl#getR0 <em>R0</em>}</li>
 *   <li>{@link EA_Model.IEC61970.Wires.impl.EnergySourceImpl#getRn <em>Rn</em>}</li>
 *   <li>{@link EA_Model.IEC61970.Wires.impl.EnergySourceImpl#getVoltageAngle <em>Voltage Angle</em>}</li>
 *   <li>{@link EA_Model.IEC61970.Wires.impl.EnergySourceImpl#getVoltageMagnitude <em>Voltage Magnitude</em>}</li>
 *   <li>{@link EA_Model.IEC61970.Wires.impl.EnergySourceImpl#getX <em>X</em>}</li>
 *   <li>{@link EA_Model.IEC61970.Wires.impl.EnergySourceImpl#getX0 <em>X0</em>}</li>
 *   <li>{@link EA_Model.IEC61970.Wires.impl.EnergySourceImpl#getXn <em>Xn</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class EnergySourceImpl extends ConductingEquipmentImpl implements EnergySource {
	/**
	 * The cached value of the '{@link #getActivePower() <em>Active Power</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getActivePower()
	 * @generated
	 * @ordered
	 */
	protected ActivePower activePower;

	/**
	 * The cached value of the '{@link #getNominalVoltage() <em>Nominal Voltage</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getNominalVoltage()
	 * @generated
	 * @ordered
	 */
	protected Voltage nominalVoltage;

	/**
	 * The cached value of the '{@link #getR() <em>R</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getR()
	 * @generated
	 * @ordered
	 */
	protected Resistance r;

	/**
	 * The cached value of the '{@link #getR0() <em>R0</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getR0()
	 * @generated
	 * @ordered
	 */
	protected Resistance r0;

	/**
	 * The cached value of the '{@link #getRn() <em>Rn</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getRn()
	 * @generated
	 * @ordered
	 */
	protected Resistance rn;

	/**
	 * The cached value of the '{@link #getVoltageAngle() <em>Voltage Angle</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getVoltageAngle()
	 * @generated
	 * @ordered
	 */
	protected AngleRadians voltageAngle;

	/**
	 * The cached value of the '{@link #getVoltageMagnitude() <em>Voltage Magnitude</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getVoltageMagnitude()
	 * @generated
	 * @ordered
	 */
	protected Voltage voltageMagnitude;

	/**
	 * The cached value of the '{@link #getX() <em>X</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getX()
	 * @generated
	 * @ordered
	 */
	protected Reactance x;

	/**
	 * The cached value of the '{@link #getX0() <em>X0</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getX0()
	 * @generated
	 * @ordered
	 */
	protected Reactance x0;

	/**
	 * The cached value of the '{@link #getXn() <em>Xn</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getXn()
	 * @generated
	 * @ordered
	 */
	protected Reactance xn;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected EnergySourceImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return WiresPackage.Literals.ENERGY_SOURCE;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ActivePower getActivePower() {
		if (activePower != null && activePower.eIsProxy()) {
			InternalEObject oldActivePower = (InternalEObject)activePower;
			activePower = (ActivePower)eResolveProxy(oldActivePower);
			if (activePower != oldActivePower) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, WiresPackage.ENERGY_SOURCE__ACTIVE_POWER, oldActivePower, activePower));
			}
		}
		return activePower;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ActivePower basicGetActivePower() {
		return activePower;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setActivePower(ActivePower newActivePower) {
		ActivePower oldActivePower = activePower;
		activePower = newActivePower;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, WiresPackage.ENERGY_SOURCE__ACTIVE_POWER, oldActivePower, activePower));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Voltage getNominalVoltage() {
		if (nominalVoltage != null && nominalVoltage.eIsProxy()) {
			InternalEObject oldNominalVoltage = (InternalEObject)nominalVoltage;
			nominalVoltage = (Voltage)eResolveProxy(oldNominalVoltage);
			if (nominalVoltage != oldNominalVoltage) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, WiresPackage.ENERGY_SOURCE__NOMINAL_VOLTAGE, oldNominalVoltage, nominalVoltage));
			}
		}
		return nominalVoltage;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Voltage basicGetNominalVoltage() {
		return nominalVoltage;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setNominalVoltage(Voltage newNominalVoltage) {
		Voltage oldNominalVoltage = nominalVoltage;
		nominalVoltage = newNominalVoltage;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, WiresPackage.ENERGY_SOURCE__NOMINAL_VOLTAGE, oldNominalVoltage, nominalVoltage));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Resistance getR() {
		if (r != null && r.eIsProxy()) {
			InternalEObject oldR = (InternalEObject)r;
			r = (Resistance)eResolveProxy(oldR);
			if (r != oldR) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, WiresPackage.ENERGY_SOURCE__R, oldR, r));
			}
		}
		return r;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Resistance basicGetR() {
		return r;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setR(Resistance newR) {
		Resistance oldR = r;
		r = newR;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, WiresPackage.ENERGY_SOURCE__R, oldR, r));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Resistance getR0() {
		if (r0 != null && r0.eIsProxy()) {
			InternalEObject oldR0 = (InternalEObject)r0;
			r0 = (Resistance)eResolveProxy(oldR0);
			if (r0 != oldR0) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, WiresPackage.ENERGY_SOURCE__R0, oldR0, r0));
			}
		}
		return r0;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Resistance basicGetR0() {
		return r0;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setR0(Resistance newR0) {
		Resistance oldR0 = r0;
		r0 = newR0;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, WiresPackage.ENERGY_SOURCE__R0, oldR0, r0));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Resistance getRn() {
		if (rn != null && rn.eIsProxy()) {
			InternalEObject oldRn = (InternalEObject)rn;
			rn = (Resistance)eResolveProxy(oldRn);
			if (rn != oldRn) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, WiresPackage.ENERGY_SOURCE__RN, oldRn, rn));
			}
		}
		return rn;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Resistance basicGetRn() {
		return rn;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setRn(Resistance newRn) {
		Resistance oldRn = rn;
		rn = newRn;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, WiresPackage.ENERGY_SOURCE__RN, oldRn, rn));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public AngleRadians getVoltageAngle() {
		if (voltageAngle != null && voltageAngle.eIsProxy()) {
			InternalEObject oldVoltageAngle = (InternalEObject)voltageAngle;
			voltageAngle = (AngleRadians)eResolveProxy(oldVoltageAngle);
			if (voltageAngle != oldVoltageAngle) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, WiresPackage.ENERGY_SOURCE__VOLTAGE_ANGLE, oldVoltageAngle, voltageAngle));
			}
		}
		return voltageAngle;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public AngleRadians basicGetVoltageAngle() {
		return voltageAngle;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setVoltageAngle(AngleRadians newVoltageAngle) {
		AngleRadians oldVoltageAngle = voltageAngle;
		voltageAngle = newVoltageAngle;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, WiresPackage.ENERGY_SOURCE__VOLTAGE_ANGLE, oldVoltageAngle, voltageAngle));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Voltage getVoltageMagnitude() {
		if (voltageMagnitude != null && voltageMagnitude.eIsProxy()) {
			InternalEObject oldVoltageMagnitude = (InternalEObject)voltageMagnitude;
			voltageMagnitude = (Voltage)eResolveProxy(oldVoltageMagnitude);
			if (voltageMagnitude != oldVoltageMagnitude) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, WiresPackage.ENERGY_SOURCE__VOLTAGE_MAGNITUDE, oldVoltageMagnitude, voltageMagnitude));
			}
		}
		return voltageMagnitude;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Voltage basicGetVoltageMagnitude() {
		return voltageMagnitude;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setVoltageMagnitude(Voltage newVoltageMagnitude) {
		Voltage oldVoltageMagnitude = voltageMagnitude;
		voltageMagnitude = newVoltageMagnitude;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, WiresPackage.ENERGY_SOURCE__VOLTAGE_MAGNITUDE, oldVoltageMagnitude, voltageMagnitude));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Reactance getX() {
		if (x != null && x.eIsProxy()) {
			InternalEObject oldX = (InternalEObject)x;
			x = (Reactance)eResolveProxy(oldX);
			if (x != oldX) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, WiresPackage.ENERGY_SOURCE__X, oldX, x));
			}
		}
		return x;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Reactance basicGetX() {
		return x;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setX(Reactance newX) {
		Reactance oldX = x;
		x = newX;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, WiresPackage.ENERGY_SOURCE__X, oldX, x));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Reactance getX0() {
		if (x0 != null && x0.eIsProxy()) {
			InternalEObject oldX0 = (InternalEObject)x0;
			x0 = (Reactance)eResolveProxy(oldX0);
			if (x0 != oldX0) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, WiresPackage.ENERGY_SOURCE__X0, oldX0, x0));
			}
		}
		return x0;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Reactance basicGetX0() {
		return x0;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setX0(Reactance newX0) {
		Reactance oldX0 = x0;
		x0 = newX0;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, WiresPackage.ENERGY_SOURCE__X0, oldX0, x0));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Reactance getXn() {
		if (xn != null && xn.eIsProxy()) {
			InternalEObject oldXn = (InternalEObject)xn;
			xn = (Reactance)eResolveProxy(oldXn);
			if (xn != oldXn) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, WiresPackage.ENERGY_SOURCE__XN, oldXn, xn));
			}
		}
		return xn;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Reactance basicGetXn() {
		return xn;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setXn(Reactance newXn) {
		Reactance oldXn = xn;
		xn = newXn;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, WiresPackage.ENERGY_SOURCE__XN, oldXn, xn));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case WiresPackage.ENERGY_SOURCE__ACTIVE_POWER:
				if (resolve) return getActivePower();
				return basicGetActivePower();
			case WiresPackage.ENERGY_SOURCE__NOMINAL_VOLTAGE:
				if (resolve) return getNominalVoltage();
				return basicGetNominalVoltage();
			case WiresPackage.ENERGY_SOURCE__R:
				if (resolve) return getR();
				return basicGetR();
			case WiresPackage.ENERGY_SOURCE__R0:
				if (resolve) return getR0();
				return basicGetR0();
			case WiresPackage.ENERGY_SOURCE__RN:
				if (resolve) return getRn();
				return basicGetRn();
			case WiresPackage.ENERGY_SOURCE__VOLTAGE_ANGLE:
				if (resolve) return getVoltageAngle();
				return basicGetVoltageAngle();
			case WiresPackage.ENERGY_SOURCE__VOLTAGE_MAGNITUDE:
				if (resolve) return getVoltageMagnitude();
				return basicGetVoltageMagnitude();
			case WiresPackage.ENERGY_SOURCE__X:
				if (resolve) return getX();
				return basicGetX();
			case WiresPackage.ENERGY_SOURCE__X0:
				if (resolve) return getX0();
				return basicGetX0();
			case WiresPackage.ENERGY_SOURCE__XN:
				if (resolve) return getXn();
				return basicGetXn();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case WiresPackage.ENERGY_SOURCE__ACTIVE_POWER:
				setActivePower((ActivePower)newValue);
				return;
			case WiresPackage.ENERGY_SOURCE__NOMINAL_VOLTAGE:
				setNominalVoltage((Voltage)newValue);
				return;
			case WiresPackage.ENERGY_SOURCE__R:
				setR((Resistance)newValue);
				return;
			case WiresPackage.ENERGY_SOURCE__R0:
				setR0((Resistance)newValue);
				return;
			case WiresPackage.ENERGY_SOURCE__RN:
				setRn((Resistance)newValue);
				return;
			case WiresPackage.ENERGY_SOURCE__VOLTAGE_ANGLE:
				setVoltageAngle((AngleRadians)newValue);
				return;
			case WiresPackage.ENERGY_SOURCE__VOLTAGE_MAGNITUDE:
				setVoltageMagnitude((Voltage)newValue);
				return;
			case WiresPackage.ENERGY_SOURCE__X:
				setX((Reactance)newValue);
				return;
			case WiresPackage.ENERGY_SOURCE__X0:
				setX0((Reactance)newValue);
				return;
			case WiresPackage.ENERGY_SOURCE__XN:
				setXn((Reactance)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case WiresPackage.ENERGY_SOURCE__ACTIVE_POWER:
				setActivePower((ActivePower)null);
				return;
			case WiresPackage.ENERGY_SOURCE__NOMINAL_VOLTAGE:
				setNominalVoltage((Voltage)null);
				return;
			case WiresPackage.ENERGY_SOURCE__R:
				setR((Resistance)null);
				return;
			case WiresPackage.ENERGY_SOURCE__R0:
				setR0((Resistance)null);
				return;
			case WiresPackage.ENERGY_SOURCE__RN:
				setRn((Resistance)null);
				return;
			case WiresPackage.ENERGY_SOURCE__VOLTAGE_ANGLE:
				setVoltageAngle((AngleRadians)null);
				return;
			case WiresPackage.ENERGY_SOURCE__VOLTAGE_MAGNITUDE:
				setVoltageMagnitude((Voltage)null);
				return;
			case WiresPackage.ENERGY_SOURCE__X:
				setX((Reactance)null);
				return;
			case WiresPackage.ENERGY_SOURCE__X0:
				setX0((Reactance)null);
				return;
			case WiresPackage.ENERGY_SOURCE__XN:
				setXn((Reactance)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case WiresPackage.ENERGY_SOURCE__ACTIVE_POWER:
				return activePower != null;
			case WiresPackage.ENERGY_SOURCE__NOMINAL_VOLTAGE:
				return nominalVoltage != null;
			case WiresPackage.ENERGY_SOURCE__R:
				return r != null;
			case WiresPackage.ENERGY_SOURCE__R0:
				return r0 != null;
			case WiresPackage.ENERGY_SOURCE__RN:
				return rn != null;
			case WiresPackage.ENERGY_SOURCE__VOLTAGE_ANGLE:
				return voltageAngle != null;
			case WiresPackage.ENERGY_SOURCE__VOLTAGE_MAGNITUDE:
				return voltageMagnitude != null;
			case WiresPackage.ENERGY_SOURCE__X:
				return x != null;
			case WiresPackage.ENERGY_SOURCE__X0:
				return x0 != null;
			case WiresPackage.ENERGY_SOURCE__XN:
				return xn != null;
		}
		return super.eIsSet(featureID);
	}

} //EnergySourceImpl
